const mongoose = require('mongoose')

const Schema = mongoose.Schema

const userSchema = new Schema({
  // 必须项
  nickName: {
    type: String,
    required: true
  },
  gender: {
    type: Number,
    required: true
  },
  language: {
    type: String,
    required: true
  },
  city: {
    type: String,
    required: true
  },
  province: {
    type: String,
    required: true
  },
  country: {
    type: String,
    required: true
  },
  avatarUrl: {
    type: String,
    required: true
  },
  openid: {
    type: String,
    required: true
  },
  userid: {
    type: String,
    required: true
  },

  // 非必须
  created_time: {
    type: Date,
    // 不能写死不加(),方法的返回值就是default的值
    default: Date.now
  },
  last_modified_time: {
    type: Date,
    default: Date.now
  },
})

module.exports = mongoose.model('User', userSchema)